import java.util.*;

public class BoundingBoxModel {

  private PVector _cornerTopLeft;
  private PVector _cornerBottomRight;

  BoundingBoxModel(PVector cornerTopLeft, PVector cornerBottomRight) {
    this._cornerTopLeft = cornerTopLeft;
    this._cornerBottomRight = cornerBottomRight;
  }

  public boolean inBoundingBox(PVector p) {
    if (p.x >= this._cornerTopLeft.x && p.x <= this._cornerBottomRight.x && p.y >= this._cornerTopLeft.y && p.y <= this._cornerBottomRight.y && p.z >= this._cornerTopLeft.z && p.z <= this._cornerBottomRight.z)
      return true;
    return false;
  }

  public void draw() {
    noFill();
    stroke(0, 255, 0);
    pushMatrix();
    translate((int)((this._cornerTopLeft.x) + ((this._cornerBottomRight.x - this._cornerTopLeft.x) / 2)), (int)((this._cornerTopLeft.y)  + ((this._cornerBottomRight.y - this._cornerTopLeft.y) / 2)), (int)((this._cornerTopLeft.z) + ((this._cornerBottomRight.z - this._cornerTopLeft.z) / 2)));
    box((int)((this._cornerBottomRight.x - this._cornerTopLeft.x)), (int)((this._cornerBottomRight.y - this._cornerTopLeft.y)), (int)((this._cornerBottomRight.z - this._cornerTopLeft.z)));   
    popMatrix();
    noStroke();
  }

  public PVector getCornerTopLeft() {
    return this._cornerTopLeft;
  }

  public PVector getCenter() {
    PVector newCenter = new PVector ( ((this._cornerTopLeft.x + this._cornerBottomRight.x )/ 2), ((this._cornerTopLeft.y + this._cornerBottomRight.y )/ 2), (this._cornerTopLeft.z + this._cornerBottomRight.z )/ 2) ;
    return newCenter;
  }

  public void setCornerTopLeft(PVector c) {
    this._cornerTopLeft = c;
  }

  public PVector getCornerBottomRight() {
    return this._cornerBottomRight;
  }

  public void setCornerBottomRight(PVector c) {
    this._cornerBottomRight = c;
  }
}

